/**
 * @Title: ApiCityController
 * @Package cn.com.yiqi.wsc.api.controller
 * @Description: TODO
 * Copyright: Copyright (c) 2016
 * Company: 成都壹柒互动科技有限公司
 * @author 会员系统组-林威
 * @date 2017/2/28 16:47
 * @version V1.0
 */
package cn.com.yiqi.wsc.api.controller;

import cn.com.yiqi.wsc.CityService;
import cn.com.yiqi.wsc.api.controller.ro.CommonRO;
import cn.com.yiqi.wsc.common.Result;
import cn.com.yiqi.wsc.common.ResultUtil;
import cn.com.yiqi.wsc.entity.City;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 *
 *@ClassName: ApiCityController
 * Description: TODO
 * @author 会员系统组-林威
 * @date 2017/2/28 16:47
 *
 */
@Controller
@ResponseBody
@RequestMapping("/api/city")
public class ApiCityController {
    @Autowired
    CityService cityService;

    @RequestMapping("/pro")
    public Result getPro(@RequestBody CommonRO ro){
        Result re = new Result();
        if(null != ro && StringUtils.isNotEmpty(ro.getSubCityCode())){
            int le = ro.getSubCityCode().length();
            if(le != 2 && le!= 4){
                return ResultUtil.fail(re,"参数错误！");
            }
        }

        List<City> pros = cityService.findBySub(ro==null?null:ro.getSubCityCode());
        re.putData("citys",pros);
        return ResultUtil.success(re);
    }

}
